function createAjax(){
    var ajax = false;
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        ajax=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        ajax=new ActiveXObject("Microsoft.XMLHTTP");
    }
    return ajax;
}
var page = 1;
var pageSize = 15;

function getMoreImg1(){
    alert('success');
}

function getMoreIndexImg()
{
    page += 1;
    var ajax = createAjax();
    var url = '/images/' + page + '/' + pageSize + '/';
    ajax.open('get', url, false);
    ajax.onreadystatechange = function(){
        if(ajax.readyState==4){
            if(ajax.status==200){
                var sHTML = '';
                imgJson = eval('('+ajax.responseText+')');
                for(var i=0;i<imgJson.images.length;i++){
                    //alert(imgJson.images[i].url);
                    commentHtml = '';
                    for (var j=0;j<imgJson.images[i].comments.length;j++){
                        commentHtml += [
                                        '<li> <!--<a class=" icon-remove" title="删除评论"></a>-->',
                                        '<a class="_4zhc5 _iqaka" title="' + imgJson.images[i].comments[i].username + '" href="/profile/' + imgJson.images[i].comments[i].user_id + '/" data-reactid=".0.1.0.0.0.2.1.2:$comment-17856951190001917.1">' + imgJson.images[i].comments[i].username + '</a>',
                                        '<span> <span>' + imgJson.images[i].comments[i].comment + '</span> </span> </li>'
                                ].join(' ');
                    }
                    sHTML += [
                                '<article class="mod"> <header class="mod-hd"> <time class="time">'+ imgJson.images[i].img_date,
                                '</time> <a href="/profile/'+ imgJson.images[i].user_id +'/" class="avatar"> <img src="'+ imgJson.images[i].user_head_url,
                                '"> </a> <div class="profile-info"> <a title="' + imgJson.images[i].user_name + '" href="/profile/' + imgJson.images[i].user_id + '/">' + imgJson.images[i].user_name,
                                '</a> </div> </header> <div class="mod-bd"> <div class="img-box"><a href="/image/'+imgJson.images[i].img_id+'/"><img src="' + imgJson.images[i].img_url,
                                '" class="img"> </a></div> </div> <div class="mod-ft"> <!-- <section class="times"><span></span> <span>6.2百万</span> <span> 次播放</span> </section> --> <ul class="discuss-list">  <li class="more-discuss"> <a> <span>全部 </span><span class="">'+ imgJson.images[i].comment_count,
                                '</span><span> 条评论</span></a> </li>',
                                 commentHtml,
                                '</ul> <!-- <section class="discuss-edit"> <a class="icon-heart"></a> <form> <input placeholder="添加评论..." type="text"> </form> <button class="more-info">更多选项</button> </section> --> </div> </article>'
                             ].join('');
                }
                var imgList = document.getElementById('img-List');
                var nextImgList = document.createElement('article');
                nextImgList.innerHTML = sHTML;
                //alert(sHTML);
                //imgList.insertBefore(nextImgList,document.getElementById("more"));
                imgList.appendChild(nextImgList);
            }
        }
        if(imgJson.has_next == false){
            document.getElementById("more").style.display = "none";
        }
    }
    ajax.send(null);
}
